// Logging_lib.h

#pragma once
#include <string>
#include <iostream>
#include <Windows.h>
#include <time.h>
using namespace std;

enum LogRate {
	Error,
	Debug,
	Warning
};

enum LogLevel
{
	ReleaseLvl,
	WarningLvl,
	DebugLvl
};

//typedef 
class Buffer
{
	static const long int maxBuffSize = 1024*1024;
	int bufferWPosition;
	
public:
	Buffer();
	LPCVOID* iBuffer;
	int WriteToBuffer(string msg);
	void ClearBuffer();
	int SizeOfInfo();

};

public class Logging
{
protected:
		Logging(string fileName);
		Logging();
private:
		static Logging* _instance;
		LogLevel Level;
		string LogRateToString(LogRate LogR);
		Buffer* FileBuffer;
		HANDLE LogFile;
		string nameLogFile;
		string nameLogFileNow;
		int numberLogFiles;

		int changeLogFileName();
		int BuffToFile();

		static const long int maxFileSize = 1024*1024*10;
public:
		static Logging* Instance();
		
		
		~Logging();
	
		int LogWrite(LogRate LogR, string msg);//return 0 if success

		void ChangeLevel(LogLevel lvl);
};

